export type MockResponse<T = any> =
  | { success: true; data: T }
  | { success: false; message: string }

export const mock = <T>(
  data: any,
  success = true
): Promise<MockResponse<T>> => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      if (success) {
        resolve({
          success: true,
          data,
        })
      } else {
        resolve({
          success: false,
          message: 'error',
        })
      }
    }, 1000)
  })
}
